<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Voya Media: MediaManagement.cs Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Voya Media
   &#160;<span id="projectnumber">1.2.255.1212</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00020.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">MediaManagement.cs</div>  </div>
</div><!--header-->
<div class="contents">
<a href="a00020.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ﻿using System;
<a name="l00002"></a>00002 <span class="keyword">using</span> System.IO;
<a name="l00003"></a>00003 <span class="keyword">using</span> System.Collections;
<a name="l00004"></a>00004 <span class="keyword">using</span> System.Collections.Generic;
<a name="l00005"></a>00005 <span class="keyword">using</span> System.Diagnostics;
<a name="l00006"></a>00006 <span class="keyword">using</span> System.Security.AccessControl;
<a name="l00007"></a>00007 <span class="keyword">using</span> System.Security.Permissions;
<a name="l00008"></a>00008 <span class="keyword">using</span> System.Text;
<a name="l00009"></a>00009 
<a name="l00010"></a><a class="code" href="a00028.html">00010</a> <span class="keyword">namespace </span>MediaManagement
<a name="l00011"></a>00011 {
<a name="l00014"></a><a class="code" href="a00009.html">00014</a>     <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="a00009.html">MediaTypeValidation</a>
<a name="l00015"></a>00015     {
<a name="l00022"></a><a class="code" href="a00009.html#aef754b1f9f1c899007323352a5a01914">00022</a>         <span class="keyword">public</span> <span class="keyword">static</span> List&lt;string&gt; <a class="code" href="a00009.html#aef754b1f9f1c899007323352a5a01914" title="Takes a string List of filenames, and returns a new string List containing only the valid video direc...">GetValidVideoDirectoriesFromFileList</a>(List&lt;string&gt; fileList)
<a name="l00023"></a>00023         {
<a name="l00024"></a>00024             <span class="comment">// Main variables.</span>
<a name="l00025"></a>00025             List&lt;string&gt; validVideoDirectories = <span class="keyword">new</span> List&lt;string&gt;() { };
<a name="l00026"></a>00026 
<a name="l00027"></a>00027             <span class="comment">// Get valid video files from the files list.</span>
<a name="l00028"></a>00028             <span class="keywordflow">foreach</span> (<span class="keywordtype">string</span> file <span class="keywordflow">in</span> fileList)
<a name="l00029"></a>00029             {
<a name="l00030"></a>00030                 FileInfo fileInfo = <span class="keyword">new</span> FileInfo(file);
<a name="l00031"></a>00031 
<a name="l00032"></a>00032                 <span class="keywordflow">if</span> (<a class="code" href="a00009.html">MediaTypeValidation</a>.<a class="code" href="a00009.html#af71f6fbbef579591e1723c809f0e9087" title="Tells you if the file is a valid video file type.">IsVideo</a>(file) &amp;&amp; !validVideoDirectories.Contains(fileInfo.DirectoryName))
<a name="l00033"></a>00033                 {
<a name="l00034"></a>00034                     validVideoDirectories.Add(fileInfo.DirectoryName);
<a name="l00035"></a>00035                 }
<a name="l00036"></a>00036             }
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 
<a name="l00039"></a>00039             <span class="comment">// Sort the list alphabetically.</span>
<a name="l00040"></a>00040             validVideoDirectories.Sort();
<a name="l00041"></a>00041 
<a name="l00042"></a>00042             <span class="comment">// Return a string List of the valid video files.</span>
<a name="l00043"></a>00043             <span class="keywordflow">return</span> validVideoDirectories;
<a name="l00044"></a>00044         }
<a name="l00045"></a>00045 
<a name="l00052"></a><a class="code" href="a00009.html#ac9025c0badc6e771284be506efb01817">00052</a>         <span class="keyword">public</span> <span class="keyword">static</span> List&lt;string&gt; <a class="code" href="a00009.html#ac9025c0badc6e771284be506efb01817" title="Takes a string List of filenames, and returns a new string List containing only the valid video filen...">GetValidVideosFromFileList</a>(List&lt;string&gt; fileList)
<a name="l00053"></a>00053         {
<a name="l00054"></a>00054             <span class="comment">// Main variables.</span>
<a name="l00055"></a>00055             List&lt;string&gt; validVideoFiles = <span class="keyword">new</span> List&lt;string&gt;() { };
<a name="l00056"></a>00056 
<a name="l00057"></a>00057             <span class="comment">// Get valid video files from the files list.</span>
<a name="l00058"></a>00058             <span class="keywordflow">foreach</span> (<span class="keywordtype">string</span> file <span class="keywordflow">in</span> fileList)
<a name="l00059"></a>00059             {
<a name="l00060"></a>00060                 <span class="keywordflow">if</span> (<a class="code" href="a00009.html">MediaTypeValidation</a>.<a class="code" href="a00009.html#af71f6fbbef579591e1723c809f0e9087" title="Tells you if the file is a valid video file type.">IsVideo</a>(file))
<a name="l00061"></a>00061                 {
<a name="l00062"></a>00062                     validVideoFiles.Add(file);
<a name="l00063"></a>00063                 }
<a name="l00064"></a>00064             }
<a name="l00065"></a>00065 
<a name="l00066"></a>00066             <span class="comment">// Return a string List of the valid video files.</span>
<a name="l00067"></a>00067             <span class="keywordflow">return</span> validVideoFiles;
<a name="l00068"></a>00068         }
<a name="l00069"></a>00069 
<a name="l00076"></a><a class="code" href="a00009.html#a6e4e214a3efa98101f2cb27aad01c52f">00076</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00009.html#a6e4e214a3efa98101f2cb27aad01c52f" title="Tells you if the file is a valid audio file type.">IsAudio</a>(<span class="keywordtype">string</span> fileNameAndPath)
<a name="l00077"></a>00077         {
<a name="l00078"></a>00078             <span class="comment">// Make a list of valid audio file extensions.</span>
<a name="l00079"></a>00079             List&lt;string&gt; audioExtensions = <span class="keyword">new</span> List&lt;string&gt;() { <span class="stringliteral">@&quot;.aac&quot;</span>, <span class="stringliteral">@&quot;.aif&quot;</span>, <span class="stringliteral">@&quot;.iff&quot;</span>, <span class="stringliteral">@&quot;.m4a&quot;</span>, <span class="stringliteral">@&quot;.mid&quot;</span>, <span class="stringliteral">@&quot;.mp3&quot;</span>, <span class="stringliteral">@&quot;.mpa&quot;</span>, <span class="stringliteral">@&quot;.wav&quot;</span>, <span class="stringliteral">@&quot;.wma&quot;</span> };
<a name="l00080"></a>00080 
<a name="l00081"></a>00081             <span class="comment">// Get the details and properties of the file.</span>
<a name="l00082"></a>00082             FileInfo fileInfo = null;
<a name="l00083"></a>00083 
<a name="l00084"></a>00084             <span class="comment">// Check if the fully qualified file name is less than MAX_CHARS of 260 characters.</span>
<a name="l00085"></a>00085             <span class="keywordflow">if</span> (fileNameAndPath.Length &lt; 260)
<a name="l00086"></a>00086             {
<a name="l00087"></a>00087                 fileInfo = <span class="keyword">new</span> FileInfo(fileNameAndPath);
<a name="l00088"></a>00088             }
<a name="l00089"></a>00089 
<a name="l00090"></a>00090             <span class="comment">// Validate the file extension.</span>
<a name="l00091"></a>00091             <span class="keywordflow">if</span> (fileInfo != null)
<a name="l00092"></a>00092             {
<a name="l00093"></a>00093                 <span class="keywordflow">if</span> (audioExtensions.Contains(fileInfo.Extension.ToLower()))
<a name="l00094"></a>00094                 {
<a name="l00095"></a>00095                     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00096"></a>00096                 }
<a name="l00097"></a>00097             }
<a name="l00098"></a>00098 
<a name="l00099"></a>00099             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00100"></a>00100         }
<a name="l00101"></a>00101 
<a name="l00108"></a><a class="code" href="a00009.html#a2398bc5d1da95ef4fc16f66768def12b">00108</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00009.html#a2398bc5d1da95ef4fc16f66768def12b" title="Tells you if the file is a valid picture file type.">IsPicture</a>(<span class="keywordtype">string</span> fileNameAndPath)
<a name="l00109"></a>00109         {
<a name="l00110"></a>00110             <span class="comment">// Make a list of valid picture file extensions.</span>
<a name="l00111"></a>00111             List&lt;string&gt; pictureExtensions = <span class="keyword">new</span> List&lt;string&gt;() { <span class="stringliteral">@&quot;.bmp&quot;</span>, <span class="stringliteral">@&quot;.gif&quot;</span>, <span class="stringliteral">@&quot;.jpg&quot;</span>, <span class="stringliteral">@&quot;.png&quot;</span>, <span class="stringliteral">@&quot;.psd&quot;</span>, <span class="stringliteral">@&quot;.tif&quot;</span> };
<a name="l00112"></a>00112 
<a name="l00113"></a>00113             <span class="comment">// Get the details and properties of the file.</span>
<a name="l00114"></a>00114             FileInfo fileInfo = null;
<a name="l00115"></a>00115 
<a name="l00116"></a>00116             <span class="comment">// Check if the fully qualified file name is less than MAX_CHARS of 260 characters.</span>
<a name="l00117"></a>00117             <span class="keywordflow">if</span> (fileNameAndPath.Length &lt; 260)
<a name="l00118"></a>00118             {
<a name="l00119"></a>00119                 fileInfo = <span class="keyword">new</span> FileInfo(fileNameAndPath);
<a name="l00120"></a>00120             }
<a name="l00121"></a>00121 
<a name="l00122"></a>00122             <span class="comment">// Validate the file extension.</span>
<a name="l00123"></a>00123             <span class="keywordflow">if</span> (fileInfo != null)
<a name="l00124"></a>00124             {
<a name="l00125"></a>00125                 <span class="keywordflow">if</span> (pictureExtensions.Contains(fileInfo.Extension.ToLower()))
<a name="l00126"></a>00126                 {
<a name="l00127"></a>00127                     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00128"></a>00128                 }
<a name="l00129"></a>00129             }
<a name="l00130"></a>00130 
<a name="l00131"></a>00131             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00132"></a>00132         }
<a name="l00133"></a>00133 
<a name="l00140"></a><a class="code" href="a00009.html#af71f6fbbef579591e1723c809f0e9087">00140</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00009.html#af71f6fbbef579591e1723c809f0e9087" title="Tells you if the file is a valid video file type.">IsVideo</a>(<span class="keywordtype">string</span> fileNameAndPath)
<a name="l00141"></a>00141         {
<a name="l00142"></a>00142             <span class="comment">// Make a list of valid video file extensions.</span>
<a name="l00143"></a>00143             List&lt;string&gt; videoExtensions = <span class="keyword">new</span> List&lt;string&gt;() { <span class="stringliteral">@&quot;.3g2&quot;</span>, <span class="stringliteral">@&quot;.3gp&quot;</span>, <span class="stringliteral">@&quot;.asf&quot;</span>, <span class="stringliteral">@&quot;.asx&quot;</span>, <span class="stringliteral">@&quot;.avi&quot;</span>, <span class="stringliteral">@&quot;.flv&quot;</span>, <span class="stringliteral">@&quot;.m2ts&quot;</span>, <span class="stringliteral">@&quot;.m4v&quot;</span>, <span class="stringliteral">@&quot;.mkv&quot;</span>, <span class="stringliteral">@&quot;.mov&quot;</span>, <span class="stringliteral">@&quot;.mp4&quot;</span>, <span class="stringliteral">@&quot;.mpg&quot;</span>, <span class="stringliteral">@&quot;.swf&quot;</span>, <span class="stringliteral">@&quot;.ts&quot;</span>, <span class="stringliteral">@&quot;.vob&quot;</span>, <span class="stringliteral">@&quot;.wmv&quot;</span> };
<a name="l00144"></a>00144 
<a name="l00145"></a>00145             <span class="comment">// Get the details and properties of the file.</span>
<a name="l00146"></a>00146             FileInfo fileInfo = null;
<a name="l00147"></a>00147 
<a name="l00148"></a>00148             <span class="comment">// Check if the fully qualified file name is less than MAX_CHARS of 260 characters.</span>
<a name="l00149"></a>00149             <span class="keywordflow">if</span> (fileNameAndPath.Length &lt; 260)
<a name="l00150"></a>00150             {
<a name="l00151"></a>00151                 fileInfo = <span class="keyword">new</span> FileInfo(fileNameAndPath);
<a name="l00152"></a>00152             }
<a name="l00153"></a>00153 
<a name="l00154"></a>00154             <span class="comment">// Validate the file extension.</span>
<a name="l00155"></a>00155             <span class="keywordflow">if</span> (fileInfo != null)
<a name="l00156"></a>00156             {
<a name="l00157"></a>00157                 <span class="keywordflow">if</span> (videoExtensions.Contains(fileInfo.Extension.ToLower()))
<a name="l00158"></a>00158                 {
<a name="l00159"></a>00159                     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00160"></a>00160                 }
<a name="l00161"></a>00161             }
<a name="l00162"></a>00162 
<a name="l00163"></a>00163             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00164"></a>00164         }
<a name="l00165"></a>00165 
<a name="l00166"></a>00166     }
<a name="l00167"></a>00167 
<a name="l00168"></a>00168 }
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00020.html">MediaManagement.cs</a>      </li>

    <li class="footer">Generated on Thu Jan 10 2013 07:05:20 for Voya Media by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.0 </li>
   </ul>
 </div>


</body>
</html>
